package com.stream_liu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.stream.Stream;

public class StreamDemo {
    public static void main(String[] args) {
        // Collection体系的结合可以使用默认方法stream()生成流
        ArrayList<String> list1 = new ArrayList<>();
        Stream<String> stream = list1.stream();

        HashSet<String> set1 = new HashSet<>();
        Stream<String> stream1 = set1.stream();

        // map体系的集合间接生成流
        Map<String, Integer> map1 = new HashMap<>();
        Stream<String> keyStream = map1.keySet().stream();
        Stream<Integer> valueStream = map1.values().stream();
        Stream<Map.Entry<String, Integer>> entryStr = map1.entrySet().stream();

        // 数组可以通过Stream接口的静态方法of(T...values)生成流
        String[] strArray = {"hello", "world", "java"};
        Stream<String> strArrayStream = Stream.of(strArray);
        Stream<String> strArrayStream1 = Stream.of("hello", "world", "java");
        Stream<Integer> intStream = Stream.of(10, 20, 30);
    }
}